//
//  VideoCallingEnterViewController.m
//  TRTC-API-Example-OC
//
//  Created by bluedang on 2021/4/12.
//
//  TRTC 视频通话入口界面
//  包含如下功能：
//  1、 进入房间，生成音频通话界面

#import "VideoCallingEnterViewController.h"
#import "VideoCallingViewController.h"
#import "RoomPkViewController.h"

@interface VideoCallingEnterViewController ()
@property (weak, nonatomic) IBOutlet UITextField *userIdTextField;
@property (weak, nonatomic) IBOutlet UITextField *roomIdTextField;
@property (weak, nonatomic) IBOutlet UILabel *inputRoomLabel;
@property (weak, nonatomic) IBOutlet UILabel *inputUserLabel;
@property (weak, nonatomic) IBOutlet UIButton *startButton;
@end

@implementation VideoCallingEnterViewController

- (instancetype)init {
    self = [super initWithNibName:NSStringFromClass([self class]) bundle:nil];
    if (self) {
    }
    return  self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupNaviBarStatus];
    
    [self setupDefaultUIConfig];
    [self setupRandomId];
}

- (void)setupDefaultUIConfig {
    self.title = Localize(@"TRTC-API-Example.VideoCallingEnter.Title");
    _inputRoomLabel.text = Localize(@"TRTC-API-Example.VideoCallingEnter.EnterRoomNumber");
    _inputUserLabel.text = Localize(@"TRTC-API-Example.VideoCallingEnter.EnterUserName");
    [_startButton setTitle:Localize(@"TRTC-API-Example.VideoCallingEnter.EnterRoom") forState:UIControlStateNormal];
}

- (void)setupRandomId {
    _roomIdTextField.text = @"999";
    _userIdTextField.text = [NSString generateRandomUserId];
}

- (IBAction)onStartClick:(id)sender {
//    VideoCallingViewController *videoCallingVC = [[VideoCallingViewController alloc]
//                                                  initWithRoomId:[_roomIdTextField.text intValue]
//                                                  userId:_userIdTextField.text];
//    [self.navigationController pushViewController:videoCallingVC animated:YES];
    RoomPkViewController *vc = [[RoomPkViewController alloc] init];
    vc.localRoomId = self.roomIdTextField.text;
    vc.localUserId = self.userIdTextField.text;
    [self.navigationController pushViewController:vc animated:YES];
    
}



- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];
    [self.view endEditing:true];
}


- (void)setupNaviBarStatus {
    self.navigationItem.title = Localize(@"TRTC-API-Example.Home.Title");
    [self.navigationController setNavigationBarHidden:false animated:false];
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    self.navigationController.navigationBar.translucent = YES;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
}

@end
